/** /////////////////////////////////////////////////////////////////////////////////
 * @author		Jaeger, Mathias
 * @function 	Listener zu Key-Events initialisieren.
 * @param		
 /////////////////////////////////////////////////////////////////////////////////*/


function keyEventSetup(){
	// Referenz auf keyboard laesst sich mit keyboard.destroy() wieder deaktivieren
	laneAssist.keyboard = new THREEx.KeyboardState();

	// Nur keydown-Events
	laneAssist.keyboard.domElement.addEventListener('keydown', function(event) {

		// Beschleunigen
		if (laneAssist.keyboard.pressed("w") || laneAssist.keyboard.pressed("up")) {
			beschleunigen(0.25);
		}
		if (laneAssist.keyboard.pressed("s") || laneAssist.keyboard.pressed("down")) {
			abbremsen(2);
		}
		// Nach links lenken
		if (laneAssist.keyboard.eventMatches(event, 'a') || laneAssist.keyboard.eventMatches(event, 'left')) {
			laneAssist.laneAssistAktiv = false;
			blinker_links = true;
			blinkerVorneSprite_links.visible = true;
			blinkerSeiteSprite_links.visible = true;
			blinkerHintenSprite_links.visible = true;
		}
		if (laneAssist.keyboard.eventMatches(event, 'd') || laneAssist.keyboard.eventMatches(event, 'right')) {
			laneAssist.laneAssistAktiv = false;
			blinker_rechts = true;
			blinkerVorneSprite_rechts.visible = true;
			blinkerSeiteSprite_rechts.visible = true;
			blinkerHintenSprite_rechts.visible = true;
		}
	});

	// Nur keyup-Events
	laneAssist.keyboard.domElement.addEventListener('keyup', function(event) {
		// Nicht mehr nach links lenken
		if (laneAssist.keyboard.eventMatches(event, 'a') || laneAssist.keyboard.eventMatches(event, 'left')) {
			blinker_links = false;
			blinkerVorneSprite_links.visible = false;
			blinkerSeiteSprite_links.visible = false;
			blinkerHintenSprite_links.visible = false;
			zuNullLenken();
		}
		if (laneAssist.keyboard.eventMatches(event, 'd') || laneAssist.keyboard.eventMatches(event, 'right')) {
			blinker_rechts = false;
			blinkerVorneSprite_rechts.visible = false;
			blinkerSeiteSprite_rechts.visible = false;
			blinkerHintenSprite_rechts.visible = false;
			zuNullLenken();
		}
	});
};